﻿using ArtClub.Controller;
using ArtClub.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;


namespace UI
{
	/// <summary>
	/// Interaction logic for CreateArt.xaml
	/// </summary>
	public partial class CreateArt : UserControl

	{
        #region fields
        private ArtCtr artCtr = new ArtCtr();
        private Art art = new Art();
        #endregion
		public CreateArt()
		{
			InitializeComponent();
		}

        private void ButtonAttach_Click(object sender, RoutedEventArgs e)
        {
			try
			{
                Picture.Source = new BitmapImage(new Uri(TextboxDirection.Text));
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message);
			}
        }

        private void ButtonRegister_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                art.Description = TextboxDescription.Text;
                art.Name = TextboxArtName.Text;
                art.Price = double.Parse(TextboxMinPrice.Text);
                art.Measurement = TextboxMesaurement.Text;
                art.Direction = TextboxDirection.Text;

                MessageBox.Show("Kunst Oprettet");

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            artCtr.Create(art);

            //grim kode
            CreateAuction ca = new CreateAuction();
            ca.PopulateListArt();
        }

        private void ButtonReset_Click(object sender, RoutedEventArgs e)
        {
            TextboxDescription.Clear();
            TextboxArtName.Clear();
            TextboxMinPrice.Clear();
            TextboxMesaurement.Clear();
            TextboxDirection.Clear();
        }
	}
}
